<template>
  <div>
    <template v-if="stationOptions.length > 0">
      <a-radio-group
        v-if="type === 'radio'"
        :options="stationOptions"
        v-model:value="modelValue"
        v-bind="$attrs"
        :disabled="disabled"
      ></a-radio-group>
      <a-select
        v-else
        :options="stationOptions"
        v-model:value="modelValue"
        v-bind="$attrs"
        :disabled="disabled"
        allow-clear
      ></a-select>
    </template>

    <div v-else class="text-gray-400">没有数据</div>
  </div>
</template>

<script setup lang="ts">
import { stationOptions, getStationOptions } from '@/api/modules/utils/data';

const modelValue = defineModel<string>('modelValue');
withDefaults(
  defineProps<{
    disabled?: boolean;
    type?: 'select' | 'radio';
  }>(),
  {
    type: 'radio',
  },
);
onMounted(() => {
  getStationOptions();
});
</script>

<style lang="scss" scoped></style>
